package com.xzit.xzitexprement2.Controller;

import com.xzit.xzitexprement2.Pojo.result;
import com.xzit.xzitexprement2.Pojo.students;
import com.xzit.xzitexprement2.Service.studentsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/students")
public class studentsController {
    @Autowired
    private studentsService studentsservice;
    @GetMapping("/listAll")
    public result listAll(){
        return result.success(studentsservice.listAll());
    }
    @GetMapping("/getById/{studentId}")
    public result getById(@PathVariable String studentId){
        return result.success(studentsservice.getById(studentId));
    }
    @PostMapping("/add")
    public result add(@RequestBody students Students){
        studentsservice.add(Students);
        return result.success();
    }
}
